#include <REGX52.H>
#include <stdio.h>
#include "LCD1602.h"
#include "Delay.h"
#include "IR.h"

unsigned char Num;
unsigned char Address;
unsigned char Command;

void main() {
    LCD_Init();
    IR_Init();
    LCD_ShowString(1,1,"ADR");
    LCD_ShowString(1,5,"CMD");
    LCD_ShowString(1,9,"NUM");
    LCD_ShowHexNum(2,1,0,2);
    LCD_ShowHexNum(2,5,0,2);
    LCD_ShowNum(2,9,0,3);
    while(1) {
        if(IR_GetDataFlag()||IR_GetRepeatFlag()) {
            Address = IR_GetAddress();
            Command = IR_GetCommand();
            LCD_ShowHexNum(2,1,Address,2);
            LCD_ShowHexNum(2,5,Command,2);

            if(Command==IR_VOL_MINUS)
                Num--;
            if(Command==IR_VOL_ADD)
                Num++;
            LCD_ShowNum(2,10,Num,2);
        }
    }
}